import {Injectable} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {_HttpClient} from '@delon/theme';
import {Apivo} from '../apivo';
import {Videotab} from './videotab';
import {of} from 'rxjs/observable/of';
import {map} from 'rxjs/operators';
import {Video} from './video';

@Injectable()
export class VideoService {


    url_vedio_add = 'lights/addlight';
    url_vedio_list = 'lights/alllightlist';
    url_vedio_show = 'lights/eshow';
    url_vedio_del = 'lights/dellight';

    url_lay_list = 'lights/list';
    url_lay_add = 'lights/addlay';
    url_lay_show = 'lights/showlay';
    url_lay_del = 'lights/dellay';

    constructor(private http: _HttpClient) {
    }

    getlaylist(page: number): Observable<Videotab[]> {
        return this.http.get(this.url_lay_list).pipe(
            map(res => res['list'])
        );
    }

    addlay(lay: Videotab): Observable<string> {
        return this.http.post(this.url_lay_add, JSON.stringify(lay));
    }

    addVedio(item): Observable<string> {
        return this.http.post(this.url_vedio_add, JSON.stringify(item));
    }

    getVedioList(page): Observable<any> {
        return this.http.get(this.url_vedio_list, {page: page});
    }


    getVeid(id: number): Observable<any> {
        return this.http.get(this.url_vedio_show, {id: id});
    }

    getlay(id: number): Observable<any> {
        return this.http.get(this.url_lay_show, {id: id});
    }

    dellay(id: number): Observable<any> {
        return this.http.delete(this.url_lay_del, {id: id});
    }

    dellight(id: number): Observable<any> {
        return this.http.delete(this.url_vedio_del, {id: id});
    }
}
